<form class="layui-form layui-form-pane" action="/core/enterprise.user/usernameLogin?eid={$enterprise.id}" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
            <input type="text" name="username" placeholder="请输入用户名" required
                   autocomplete="off"
                   class="layui-input" lay-verify="username"
                   lay-verType="tips"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" placeholder="请输入密码" required
                   autocomplete="off"
                   class="layui-input" lay-verify="password"
                   lay-verType="tips"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图形验证码</label>
        <div class="layui-input-inline captcha-verify">
            <input type="text" name="code" placeholder="请输入图形验证码" required autocomplete="off"
                   class="layui-input" lay-verify="required"
                   lay-verType="tips"/>
            <img class="captcha" src="{:captcha_src()}"
                 onclick="this.src='{:captcha_src()}?_='+new Date().getTime();"/>
        </div>
    </div>
    <div class="layui-form-item">
        <button class="layui-btn layui-btn-fluid" lay-filter="username-login" lay-submit>登 录</button>
    </div>
</form>

<script type="text/javascript">
    layui.use(['form', 'element'], function () {
        var form = layui.form;
        var element = layui.element;
        form.render();

        form.verify({
            username: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (!value) {
                    return '请输入用户名';
                }
            },
            password: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (!value) {
                    return '请输入密码';
                }
            }
        });

        form.on('submit(username-login)', function (data) {
            console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
            console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
            console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            return true; //返回false阻止表单跳转
        });
    });
</script>